import time

from selenium import webdriver
from selenium.webdriver.common.by import By

from base.base_page import BasePage


class PageLogin(BasePage):
# /driver 通过测试脚本获取的driver对象
    def __init__(self, driver: webdriver):

        # 以下是子类的自己的属性
        super().__init__(driver)
        self.__username=By.CSS_SELECTOR,"#username"
        self.__password=By.CSS_SELECTOR,"#password"
        self.__verify_code=By.CSS_SELECTOR,"#verify_code"
        self.__sbt_button=By.CSS_SELECTOR,"a[name='sbtbutton']"
        self.__login_success_text=By.CSS_SELECTOR,"a[title='退出']"
        self.__login_failure_text=By.CSS_SELECTOR,".layui-layer-content.layui-layer-padding"
    #先输入用户名
    def __input_username(self,username):
        # self.find_ele(self.__username).send_keys(username)
        self.ele_input(self.__username,username)
    #输入密码
    def __input_password(self,password):
       self.ele_input(self.__password,password)
    #输入验证码
    def __input_verify_code(self,verify_code):
        self.ele_input(self.__verify_code,verify_code)
    #点击登录按钮
    def __click_login_button(self):
        self.ele_click(self.__sbt_button)
    #获取登录成功的文本信息
    def get_login_success_text(self):
        return self.get_ele_text(self.__login_success_text)

    #获取登录失败的文本信息
    def get_login_failure_text(self):
        return self.get_ele_text(self.__login_failure_text)
    #登录方法
    def login(self,username,password,verify_code):
        self.__input_username(username)
        self.__input_password(password)
        self.__input_verify_code(verify_code)
        self.__click_login_button()

    def login2(self,username,password,verify_code):
        self.ele_input(self.__username, username)
        self.ele_input(self.__password, password)
        self.ele_input(self.__verify_code, verify_code)
        self.ele_click(self.__sbt_button)
        self.__input_verify_code(verify_code)



